package com.netposa.datawarehouse.statistics.controller;

import com.netposa.appwebres.WebResCallback;
import com.netposa.appwebres.common.WebResCriteria;
import com.netposa.appwebres.common.WebResInfo;
import com.netposa.datawarehouse.statistics.service.MaintenanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/mainterance"})
public class MaintenanceController {
   @Autowired
   MaintenanceService maintenanceService;

   @GetMapping({"/device_state"})
   public WebResInfo deviceState() {
      return (new WebResCallback() {
         public void execute(WebResCriteria criteria, Object... params) {
            criteria.addSingleResult(MaintenanceController.this.maintenanceService.deviceState());
         }
      }).sendRequest(new Object[0]);
   }

   @GetMapping({"/machine_count"})
   public WebResInfo machineCount() {
      return (new WebResCallback() {
         public void execute(WebResCriteria criteria, Object... params) {
            criteria.addSingleResult(MaintenanceController.this.maintenanceService.machineCount());
         }
      }).sendRequest(new Object[0]);
   }

   @GetMapping({"/machine_state"})
   public WebResInfo machineState() {
      return (new WebResCallback() {
         public void execute(WebResCriteria criteria, Object... params) {
            criteria.addSingleResult(MaintenanceController.this.maintenanceService.machineState());
         }
      }).sendRequest(new Object[0]);
   }
}
